package com.zx.system.block.param;

import com.zx.validation.annotation.ParameterValidation;
import com.zx.validation.enums.ValidateRulesEnum;
import com.zx.validation.groups.Create;
import com.zx.validation.groups.StatusUpdate;
import com.zx.validation.groups.Update;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Set;

/**
 * <p>
 * description: 菜单请求参数 <br>
 * create: 2024-12-15 11:35
 * </p>
 *
 * @author zhou  xun
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class MenuParam implements Create, Update, StatusUpdate {
    /**
     * 菜单ID
     */
    @ParameterValidation(index = 0, desc = "菜单ID", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~32")
    private String id;

    /**
     * 菜单名称
     */
    @ParameterValidation(index = 0, desc = "菜单名称", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~30")
    private String name;

    /**
     * 父菜单ID
     */
    @ParameterValidation(index = 0, desc = "父菜单ID", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~32")
    private String parentId;

    /**
     * 显示顺序
     */
    @ParameterValidation(index = 0, desc = "显示顺序", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.NON_NEGATIVE_NUMBER})
    private Integer seqNo;

    /**
     * 菜单类型 D目录 M菜单 B按钮
     */
    @ParameterValidation(index = 0, desc = "菜单类型", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~1")
    private String menuType;
    /**
     * 请求地址
     */
    @ParameterValidation(index = 0, desc = "请求地址", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String url;

    /**
     * 权限标识
     */
    @ParameterValidation(index = 0, desc = "权限标识", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~100")
    private String perms;
    /**
     * 菜单状态（0停用 1启用)
     */
    @ParameterValidation(index = 0, desc = "菜单状态", rules = {ValidateRulesEnum.NOT_NULL})
    private Integer status;
//----前端控制属性-------------------------------------------------------
    /**
     * 是否在侧边栏隐藏（0显示 1隐藏)
     */
    private Integer hidden;

    /**
     * 是否始终显示根菜单(1显示 0不显示)
     * 当项目有多个子路由时，会变成嵌套模式，否则不显示根菜单
     */
    private Integer alwaysShow;

    /**
     * 侧边栏和面包屑中显示的名称
     */
    @ParameterValidation(index = 0, desc = "显示名称", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~30")
    private String title;

    /**
     * 重定向地址，当设置 noRedirect 的时候该路由在面包屑导航中不可被点击
     */
    @ParameterValidation(index = 0, desc = "重定向地址", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String redirect;
    /**
     * 路由名称
     */
    //按钮不需要验证
    //@ParameterValidation(index = 0, desc = "路由名称", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~30", groups = {Create.class, Update.class})
    private String routeName;
    /**
     * 当前组件名称 ,为了兼容keep-alive缓存,componentName必须和前端组件的组件名一致,默认和文件名一致就可以了
     */
    //按钮不需要验证
    //@ParameterValidation(index = 0, desc = "组件名称", rules = {ValidateRulesEnum.NOT_NULL, ValidateRulesEnum.LENGTH}, length = "0~30", groups = {Create.class, Update.class})
    private String componentName;
    /**
     * 当前路由外层包裹的组件信息(嵌套路由)
     */
    @ParameterValidation(index = 0, desc = "组件信息", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String component;
    //------以下为mata---------------
    /**
     * 外部链接地址
     */
    @ParameterValidation(index = 0, desc = "外部链接地址", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String href;

    /**
     * 侧边栏中显示的图标
     */
    @ParameterValidation(index = 0, desc = "图标", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String icon;

    /**
     * 如果设置为0，页面将不会被缓存（0不缓存 1缓存)控制前端vue keepAlive内置组件
     */
    private Integer componentCache;

    /**
     * 如果设置为true，标签将附加在标签视图中
     */
    private Integer affix;

    /**
     * 如果设置为0，该项目将隐藏在breadcrumb中(默认为0,0显示 1隐藏)
     */
    private Integer breadcrumb;

    /**
     * 如果设置路径，侧边栏会突出显示您设置的路径(例: '/example/list')
     */
    @ParameterValidation(index = 0, desc = "活动菜单", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String activeMenu;
//-----------------------------------------------------------------------

    /**
     * 创建者
     */
    private String createBy;

    /**
     * 更新者
     */
    private String updateBy;

    /**
     * 备注
     */
    @ParameterValidation(index = 0, desc = "备注", rules = {ValidateRulesEnum.NULL_LENGTH}, length = "0~200")
    private String remark;

    @Override
    public Set<String> getCreateGroupFields() {
        return Set.of("name", "parentId", "seqNo", "menuType", "url", "perms", "status", "title", "redirect",
                "component", "href", "icon", "activeMenu", "remark");
    }

    @Override
    public Set<String> getUpdateGroupFields() {
        return Set.of("id", "name", "parentId", "seqNo", "menuType", "url", "perms", "status", "title", "redirect",
                "component", "href", "icon", "activeMenu", "remark");
    }

    @Override
    public Set<String> getStatusUpdateGroupFields() {
        return Set.of("id", "status");
    }
}